<template>
    <!--    <div>载体</div>-->
    <div class="app-container">
        <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
            <el-form-item label="数据包名称">
                <el-input v-model="queryParams.title" placeholder="请输入数据包名称" clearable style="width: 240px"
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="接收日期">
                <el-date-picker v-model="queryParams.receivingTime" type="date" placeholder="选择日期" format="yyyy-MM-dd"
                    value-format="yyyy-MM-dd">
                </el-date-picker>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
            </el-form-item>
        </el-form>
        <!-- <el-row :gutter="10" class="mb8" ref="refbut">
         
            <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
        </el-row> -->

        <el-table ref="table" v-loading="loading" :data="dataList" :height="tableHeight"
            @selection-change="handleSelectionChange" border stripe  @sort-change="sortChange">
            <el-table-column type="selection" width="50" align="center" fixed="left" />
            <el-table-column label="序号"  align="center" type="index" prop="id" :sortable="sortable"/>
            <el-table-column label="数据包名称" prop="TITLE" align="center" :show-overflow-tooltip="true" :sortable="sortable"/>
            <el-table-column label="大小(字节)" prop="SIZE" align="center" :show-overflow-tooltip="true" :sortable="sortable"/>
           <el-table-column label="保存时间（年）" prop="SAVE_TIME" align="center" :sortable="sortable">
            <template slot-scope="scope">
                   
                   <span v-for="item in dict.type.BGQX" :key="item.value">{{ scope.row.SAVE_TIME==item.value?item.label:"" }}</span>
                </template>
            </el-table-column>
              <el-table-column label="接收日期" prop="RECEIVINGTIME" align="center" :sortable="sortable"></el-table-column>
            <el-table-column label="格式" prop="FORMAT" align="center" :sortable="sortable"></el-table-column>
            <el-table-column label="存储路径" prop="PATH" align="center" :sortable="sortable"></el-table-column>
           <el-table-column label="是否解析" prop="RESOLVED" align="center" :show-overflow-tooltip="true" :sortable="sortable">
                <template slot-scope="scope">
                    {{ scope.row.RESOLVED == '1' ? '是' : '否' }}
                </template>
            </el-table-column>
            <el-table-column label="出库状体" prop="RESOLVED" align="center" :show-overflow-tooltip="true" :sortable="sortable">
                <template slot-scope="scope">
                    <!-- chuku_state=0为审批中,1已出库, 其余 未出库,       -----------------已出库才可以下载-->
                    <span v-if="scope.row.CHUKU_STATE=='0'">审批中</span>
                    <span v-else-if="scope.row.CHUKU_STATE=='1'">已出库</span>
                    <span v-else>未出库</span>
                </template>
            </el-table-column>
            <el-table-column label="是否通过检测" prop="SIXING" align="center" :sortable="sortable">
         
                <template slot-scope="scope">
                    <span v-if="scope.row.SIXING == '200'">通过</span>
                    <span v-else-if="scope.row.SIXING == '400'">不通过</span>
                    <span v-else>未检测</span>
                </template>
            </el-table-column>
            <el-table-column label="备注" prop="REMARK" align="center"></el-table-column>
            <el-table-column label="操作" align="center" width="300px">
                <template slot-scope="scope">
                    <el-button plain type="success" size="mini" @click="handleState(scope.row)">发起审批</el-button>
                    <el-button type="warning" plain size="mini" @click="handleExport(scope.row)" v-if="scope.row.CHUKU_STATE=='1'">下载</el-button>
                </template>
            </el-table-column>
        </el-table>
        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
            @pagination="getList" />
       


    </div>
</template>
    
<script>
import estimateTableHeight from "@/mixins/estimateTableHeight";
import { getTableList, deleteIdentifyFqsp } from "@/api/cqbc/dataManage/dataOutBound.js"
export default {
    mixins: [estimateTableHeight], // 混入方法
    archive_Dicts: ['CARRIER_TYPE','BGQX'],
    components: {
       
    },
    data() {
        return {
            loading: true,
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 显示搜索条件
            showSearch: true,
            dataList: [],
            total: 0,
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                orderstr: undefined, //排序
                title: undefined,
                receivingTime: undefined
            },
            deitOpen: false,
            id: undefined,
            sxjcList: [],
            dialogVisible: false, //检测方案弹窗
            sxjcType: undefined,
            rows: "",
            sortable:"custom"
        }
    },
    created() {
        this.getList()
    },
    methods: {
        // 多选框选中数据
        handleSelectionChange(selection) {
            this.ids = selection.map(item => item.id)
            this.single = selection.length !== 1
            this.multiple = !selection.length
        },

        getList() {
            console.log(this.queryParams, "00000000000000000000000000000")
            getTableList(this.queryParams).then(response => {
                this.dataList = response.rows
                this.total = response.total
                this.loading = false
            })
        },


        handleQuery() {
            this.getList();
        },

        resetQuery() {
            this.queryParams = {
                pageNum: 1,
                pageSize: 10,
                receivingTime: undefined,
                title: undefined
            },
                this.getList();
        },

        /** 下载按钮操作 */
        handleExport(row) {
            console.log(row,"slkdfjsdkljfkl")
            this.download('/cqbc/chuku/download/'+row.ID, {
            }, `type_${new Date().getTime()}.zip`)
        },

        //排序
        sortChange(obj) {
            if (obj.order != null) {
                 var orderList = obj.prop + " " + obj.order.substring(0, obj.order.length - 6)
            } else {
                var orderList = ""
            }
            this.queryParams.orderstr=orderList
            this.getList();
        },
         // //发起审批
         handleState(row) {
            const id = row.ID
            this.$modal.confirm('是否确认发起审批?').then(function () { }).then(() => {
                deleteIdentifyFqsp({
                    id:id,
                }).then(res => {
                    if (res.code == "200") {
                        this.$modal.msgSuccess("发起成功");
                        this.getList();
                    }
                })
            }).catch(() => { });
        },

    }
}
</script>
    
<style></style>
    